﻿// <copyright file="AttackView.cs" company="Ecole Normale Supérieure">
// Released under GPLv2
// </copyright>
// <summary>Contains the attackView class.</summary>

namespace Sqwarea.GameLogic.View
{
    using System;
    using System.Drawing;
    using System.Runtime.Serialization;
    using Sqwarea.Persistence;

    /// <summary>
    /// This class represents an attack View (i.e. a movement of troops from the king square to another square).
    /// </summary>
    public class AttackView
    {
        /// <summary>
        /// Initializes a new instance of the AttackView class
        /// </summary>
        /// <param name="attack">attack you want the view</param>
        /// <param name="cache">kings cache used</param>
        /// <param name="precisetroops">if you have to show the troops.</param>
        public AttackView(Attack attack, IKingsCache cache, bool precisetroops)
        {
            this.ArrivalDate = attack.ArrivalDate;
            this.Destination = attack.Destination;
            this.SenderName = (cache == null) ? null : cache.GetKingById(attack.SenderId).Nickname;
            if (precisetroops)
            {
                this.TroopsNumber = attack.TroopsNumber;
            }
            else
            {
                this.TroopsNumber = null;
            }
        }

        /// <summary>
        /// Gets the name of the sender (a king) of this attack.
        /// </summary>
        public string SenderName { get; private set; }

        /// <summary>
        /// Gets the destination of this attack.
        /// </summary>
        public Point Destination { get; private set; }

        /// <summary>
        /// Gets the number of troops.
        /// </summary>
        public int? TroopsNumber { get; private set; }

        /// <summary>
        /// Gets the arrival date of troops (date of attack).
        /// </summary>
        public DateTimeOffset ArrivalDate { get; private set; }
    }
}
